package com.bsj.power.common.def.entity.locationDevice;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bsj.power.common.constant.NumericalConstants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author LiJiaXin
 * @version 1.0.0
 * @description 定位设备日志实体
 * @time 2024/12/6 9:53
 */
@Data
@TableName(value = "tab_location_device_log")
@NoArgsConstructor
@AllArgsConstructor
public class LocationDeviceLog {

    /**
     * 主键id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 类型 1离线 2上线
     */
    @TableField("type")
    private Integer type;

    /**
     * 设备号
     */
    @TableField("device_name")
    private String deviceName;

    /**
     * 设备别名
     */
    @TableField("nike_name")
    private String nikeName;

    /**
     * 设备编码
     */
    @TableField("other_name")
    private String otherName;

    /**
     * 设备类型
     */
    @TableField("device_type")
    private Integer deviceType;

    /**
     * 修改时间
     */
    @TableField("update_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /**
     * 创建时间
     */
    @TableField("create_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    public LocationDeviceLog(LocationDevice locationDevice, boolean online) {
        this.deviceName = locationDevice.getDeviceName();
        this.nikeName = locationDevice.getNikeName();
        this.otherName = locationDevice.getOtherName();
        //暂时只有基站
        this.deviceType = NumericalConstants.ONE;
        this.type = !online ? NumericalConstants.ONE : NumericalConstants.TWO;
    }

    public LocationDeviceLog(Long id, Date updateTime) {
        this.id = id;
        this.updateTime = updateTime;
    }
}
